<template>
  <div id="printMe" style="width: 100%;">
    <div class="title">动火作业前现场检查表（检验单）</div>
    <table>
      <tr>
        <td>编号</td>
        <td colspan="3">{{ obj.serialNumber }}</td>
      </tr>
      <tr>
        <td>动火作业单位</td>
        <td>{{ obj.hotWorkUnit }}</td>
        <td>动火级别</td>
        <td>{{ obj.hotLevel }}</td>
      </tr>
      <tr>
        <td>生产运行部门</td>
        <td>{{ obj.productionDepartment }}</td>
        <td>动火时间</td>
        <td>{{ obj.hotTime | dateFormat("YYYY-MM-DD HH:mm:ss") }}</td>
      </tr>
      <tr>
        <td>动火监督部门</td>
        <td>{{ obj.supervisionDepartment }}</td>
        <td>天气情况</td>
        <td>{{ obj.weather }}</td>
      </tr>
    </table>
    <table class="content">
      <tr>
        <td>序号</td>
        <td>检查内容</td>
        <td>检查人</td>
        <td>签字</td>
      </tr>
      <tr v-for="item in hotWorkData" :key="item.code">
        <td>{{ item.sort }}</td>
        <td>{{ item.content }}</td>
        <td v-if="item.sort == 1" :rowspan="hotWorkData.length">动火作业</td>
        <td v-if="item.sort == 1" :rowspan="hotWorkData.length">{{ obj.hotWorkUserName }}</td>
      </tr>
      <tr v-for="item in productionOperationData" :key="item.code">
        <td>{{ hotWorkData.length + item.sort }}</td>
        <td>{{ item.content }}</td>
        <td v-if="item.sort == 1" :rowspan="productionOperationData.length">生产运行</td>
        <td v-if="item.sort == 1" :rowspan="productionOperationData.length">{{ obj.productionRunUserName }}</td>
      </tr>
      <tr v-for="item in hotWorkSupervisionData" :key="item.code">
        <td>{{ hotWorkData.length + productionOperationData.length + item.sort }}</td>
        <td>{{ item.content }}</td>
        <td v-if="item.sort == 1" :rowspan="hotWorkSupervisionData.length">动火监督</td>
        <td v-if="item.sort == 1" :rowspan="hotWorkSupervisionData.length">{{ obj.hotSupervisionUserName }}</td>
      </tr>
      <tr>
        <td colspan="4" class="">备注: {{ obj.remark }}</td>
      </tr>
      <tr>

        <td colspan="4" class="spyj">动火现场指挥审批意见：{{ obj.hotCommandApproval.approvalComments }}</td>
      </tr>
      <tr class="last-row">
        <td colspan="4">
          <span>签字：{{ obj.hotCommandUserName }}</span>
          <span>{{ obj.hotCommandApproval.approvalTime | dateFormat("YYYY 年 MM 月 DD 日") }}</span>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
  import {
    postHandle
  } from '@/api'
  export default {
    data() {
      return {
        maxPageSize: {
          p: 1,
          ps: 9999
        },
        hotWorkData: [],
        productionOperationData: [],
        hotWorkSupervisionData: [],
        obj: {
          hotCommandApproval: {}
        }
      }
    },
    created() {
      this.getHotWorkData()
      this.getProductionOperationData()
      this.getHotWorkSupervisionData()
    },
    methods: {
      // 动火作业
      getHotWorkData() {
        let params = {
          d: {
            filters: [{
              field: 'pdCode',
              operator: 'EQUALS',
              value: 'hotWork'
            }],
            page: this.maxPageSize,
            sorts: [{
              field: 'ct',
              isDesc: false
            }]
          }
        }
        postHandle('/api/v1/welder-sbtx-second/dictionary', params).then(res => {
          this.hotWorkData = res.result
        })
      },
      // 生产运行
      getProductionOperationData() {
        let params = {
          d: {
            filters: [{
              field: 'pdCode',
              operator: 'EQUALS',
              value: 'productionOperation'
            }],
            page: this.maxPageSize,
            sorts: [{
              field: 'ct',
              isDesc: false
            }]
          }
        }
        postHandle('/api/v1/welder-sbtx-second/dictionary', params).then(res => {
          this.productionOperationData = res.result
        })
      },
      // 动火监督
      getHotWorkSupervisionData() {
        let params = {
          d: {
            filters: [{
              field: 'pdCode',
              operator: 'EQUALS',
              value: 'hotWorkSupervision'
            }],
            page: this.maxPageSize,
            sorts: [{
              field: 'ct',
              isDesc: false
            }]
          }
        }
        postHandle('/api/v1/welder-sbtx-second/dictionary', params).then(res => {
          this.hotWorkSupervisionData = res.result
        })
      }
    }
  }
</script>

<style lang="less" scoped>
  .title {
    text-align: center;
    border: none;
    margin-bottom: 20px;
  }

  .number {
    text-align: right;
    border: none;
    width: 95%;
    margin-bottom: 20px;
  }

  table {
    border-collapse: collapse;
    width: 100%;
    border: 1px solid;

    td {
      line-height: 18px;
      border: 1px solid;
      padding: 10px;
      font-size: 14px;
    }

    td:nth-child(odd) {
      width: 20%;
    }
  }

  .content {
    border-top-color: #ffffff;

    &>tr:nth-child(1) td {
      border-top-color: #ffffff;
    }

    td:nth-child(1) {
      width: 12%;
    }

    td:nth-child(2) {
      width: 60%;
    }

    td:nth-child(3) {
      width: 16%;
    }
  }

  .last-row {
    text-align: right;

    span:nth-child(1) {
      margin-right: 50px;
    }
  }

  .spyj {
    border-bottom-color: #ffffff !important;
  }
</style>